<?php
/**
 * @author Inhere
 * @version v1.0
 * Use : form
 * Date : 2015-4-10
 */
namespace ulue\web\widgets;

use ulue\web;
use ulue\libs\form;

class ModelForm extends web\Widget
{
    public $id;

    public $action = '';

    public $method = 'post';

    public $fieldConfig = [];

    public $cssClass = [
        'errorBox' => 'error-box',
        'required' => 'required',
        'error' => 'has-error',
        'success' => 'has-success',
    ];



    /**
     * @return form\Field
     */
    public function field($model, $name)
    {
        $field = new form\Field( array_merge($this->fieldConfig, [
            'model' => $model,
            'name' => $name,
            'form' => $this
            ]) );

        return $field;
    }

    public function beginExecute()
    {
        de($this);
    }

}